<template>
  <div>
    <MyHeader title="tabBar案例"></MyHeader>

    <keep-alive>
      <div class="main">
        <component :is="type"> </component>
      </div>
    </keep-alive>
    <MyTabBar :list="tabList" @changeType="changeTypeFn"></MyTabBar>
  </div>
</template>

<script>
import "bootstrap/dist/css/bootstrap.css";
import MyHeader from "./components/MyHeader.vue";
import MyTabBar from "./components/MyTabBar.vue";
import MyGoodsList from "./views/MyGoodsList.vue";
import MyGoodsSearch from "./views/MyGoodsSearch.vue";
import MyUserInfo from "./views/MyUserInfo.vue";
export default {
  components: {
    MyHeader,
    MyTabBar,
    MyGoodsList,
    MyGoodsSearch,
    MyUserInfo,
  },
  data() {
    return {
      tabList: [
        // 底部导航的数据
        {
          iconText: "icon-shangpinliebiao",
          text: "商品列表",
          componentName: "MyGoodsList",
        },
        {
          iconText: "icon-sousuo",
          text: "商品搜索",
          componentName: "MyGoodsSearch",
        },
        {
          iconText: "icon-user",
          text: "我的信息",
          componentName: "MyUserInfo",
        },
      ],

      type: "MyGoodsList",
    };
  },

  //切换动态组件
  methods: {
    changeTypeFn(type) {
      this.type = type;
    },
  },
};
</script>

<style scoped>
.main {
  padding-top: 45px;
  padding-bottom: 51px;
}
</style>
